<template>
	<z-modaltips @confirm="confirmCancelOrder" :modelValue="modelValue" :content="state.tips" @cancel="emit('update:modelValue', false)"></z-modaltips>
</template>

<script setup>
	import sheep from "@/sheep"
	const props = defineProps({
		modelValue: {
			type: Boolean,
			default: false,
		},
		info:{
			type:Object,
			default:()=>{
				return {}
			}
		}
	});
	const emit = defineEmits(['update:modelValue', 'success']);
	const state = reactive({
		tips: '确定取消订单吗？',
	});
	watch(
		() => props.modelValue,
		(val) => {
			emit('update:modelValue', val);
		},
	);
	async function confirmCancelOrder(){
		emit('update:modelValue',false)
		const { code } = await sheep.$api.user.close_order({order_id: props.info?.id});
		if(code != 1) return
		 function success(){
		 	setTimeout(() => {
		 		uni.$emit('onReachIndex')
		 		uni.$emit('onReachOrder')
		 		sheep.$router.back()
		 	},1000)
		 }
	}
</script>

<style>
</style>